package WinterHomework.day09;

//统计字符串中的数字个数
public class Demo01 {
    public static void main(String[] args) {
        String s = "aaa222bbb444cc88";
        System.out.println(isNumeric(s));
    }

    public static int isNumeric(String str) {
        int n = 0;
        //Character.dligt()方法
        for (int i = 0; i < str.length(); i++) {
            if (Character.isDigit(str.charAt(i))) {
                n++;
            }
        }
        //Ascll码
//        for (int i = 0; i < str.length(); i++) {
//            if (str.charAt(i) >= '0' && str.charAt(i) <= '9') {
//                n++;
//            }
//        }
        return n;
    }
}
